package cn.iocoder.yudao.module.trade.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户订单邮件发送场景的枚举
 *
 * @author miaoqw
 */
@Getter
@AllArgsConstructor
public enum OrderMailSceneEnum implements IntArrayValuable {

    ORDER_PAYMENT_DETAIL(11, "order-payment-detail", "会员用户 - 订单详情"),
    ORDER_PRODUCT_REVIEW(12, "order-product-review", "会员用户 - 卡密详情"),
    ORDER_UNTREATED_WARNING(13, "order-untreated-warning", "后台管理 - 需人工处理的订单超时未处理提醒"),
    ;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(OrderMailSceneEnum::getScene).toArray();

    /**
     * 验证场景的编号
     */
    private final Integer scene;
    /**
     * 模版编码
     */
    private final String templateCode;
    /**
     * 描述
     */
    private final String description;

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static OrderMailSceneEnum getCodeByScene(Integer scene) {
        return ArrayUtil.firstMatch(sceneEnum -> sceneEnum.getScene().equals(scene),
                values());
    }

    public static OrderMailSceneEnum getByCode(String code) {
        return ArrayUtil.firstMatch(sceneEnum -> sceneEnum.getTemplateCode().equals(code),
                values());
    }

}
